package com.hoshiicloud.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 子订单状态枚举
 *
 * @author Markerccc
 * @date 2019/8/6 - 15:26
 */
@AllArgsConstructor
public enum OrderInfoStatusEnum {

    /**
     * 等待买家付款
     */
    WAIT_PAYING(0, "等待买家付款"),

    /**
     * 订单取消 (超时未付款, 买家, 商家) 没有付钱订单取消
     */
    ORDER_CANCELLATION(1, "订单取消"),
    /**
     * 清关中
     */
    CUSTOMS_CLEARANCE(2, "清关中"),
    /**
     * 清关失败
     */
    CUSTOMS_CLEARANCE_FAILURE(3, "清关失败"),
    /**
     * 等待商家发货
     */
    WAIT_SENDING_GOODS(4, "等待商家发货"),
    /**
     * 等待买家收货
     */
    WAIT_RECEIVED_GOODS(5, "等待买家收货"),
    /**
     * 未提货
     */
    WAIT_EXTRACT_GOODS(6, "待提货"),
    /**
     * 未配送
     */
    WAIT_DISTRIBUTION(7, "未配送"),
    /**
     * 配送中
     */
    DISTRIBUTION(8, "配送中"),
    /**
     * 退款成功
     */
   REFUND_SUCCESS(9, "退款成功"),
    /**
     * 已收货
     */
    RECEIVED_GOODS(10, "已收货"),
    /**
     * 已提货
     */
    EXTRACT_GOODS(11, "已提货");

    /**
     * 状态码
     */
    @Getter
    private Integer code;

    /**
     * 意义
     */
    @Getter
    private String name;

    /**
     * 根据code获取枚举
     *
     * @param code code
     * @return OrderMainStatusEnum
     */
    public static OrderInfoStatusEnum getByCode(Integer code) {
        for (OrderInfoStatusEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 根据name获取枚举
     *
     * @param name name
     * @return OrderMainStatusEnum
     */
    public static OrderInfoStatusEnum getByName(String name) {
        for (OrderInfoStatusEnum value : values()) {
            if (value.getName().equals(name)) {
                return value;
            }
        }
        return null;
    }
}
